package nio.three;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;

/*
    通过NIO实现非阻塞式群聊系统--客户端
 */
public class Client {
    public static void main(String[] args) {
        try {
            //创建客户端
            SocketChannel socketChannel = SocketChannel.open(new InetSocketAddress("localhost",8888));
            //设置为非阻塞
            socketChannel.configureBlocking(false);
            //创建一个线程来处理客户端发送消息
            new ClientSendThread(socketChannel).start();
            //创建一个线程来处理客户端接收消息
            new ClientAcceptThread(socketChannel).start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
